Fail closed when gh is absent during attestation#21
Merged
Conversation
The SLSA provenance gate for checksums.txt called gh attestation verify, but verifyChecksumsAttestationFn returned nil (pass) whenever gh was not on PATH. Headless production hosts never install gh (install.sh omits it), so the provenance check was a silent no-op there — collapsing auto-update integrity back to "anyone with GitHub repo-write access can ship a malicious release." Make attestation fail closed: when gh is missing and SkipAttestation is false, verification now returns an error and the update is refused. The only bypass is the explicit Config.SkipAttestation opt-out (intended for test repos without real attestations). The mandatory SHA256 checksums.txt match is unchanged and still enforced regardless of SkipAttestation, and both RunOnce and the gated checkLoop share applyUpdate so neither can skip the gate. Replace the test that codified "gh absent => pass" with one asserting fail-closed, and add coverage for SkipAttestation=true still requiring a SHA256 match (pass on match, refuse on mismatch).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug (H5)
The auto-updater verifies SLSA provenance of
checksums.txtviagh attestation verify, butverifyChecksumsAttestationFndidexec.LookPath("gh")and returned nil (PASS) wheneverghwas absent. On headless production hosts theinstall.shnever installsgh, so the SLSA integrity gate was a silent no-op in production — collapsing auto-update integrity back to "anyone with GitHub repo-write access (compromised PAT, supply-chain compromise) can push a malicious release and every Pilot node auto-installs it."A test (
TestVerifyChecksumsAttestation_GhNotInstalled) even codified the skip-when-absent behavior, locking the vulnerability in.The fix
ghis not on PATH andSkipAttestationisfalse, verification now returns an error (gh CLI required for SLSA attestation verification; install gh or set SkipAttestation) and the update is refused. There is no implicit skip.Config.SkipAttestation(defaultfalse) is now the sole bypass — intended for test repos that lack real attestations. Its doc comment is updated to state the security implication.checksums.txtSHA256 match is unchanged and enforced regardless ofSkipAttestation.RunOnce(manual one-shot) and the gatedcheckLoopboth funnel throughapplyUpdate, so neither can skip the gate.Refactored the production check into a named
realVerifyChecksumsAttestationFnso tests can restore it (the suite'sTestMainstubs the package var to a nil-returning func).Tests
SkipAttestation=falsevia the wrapper => error.SkipAttestation=trueend-to-end still requires a SHA256 match (installs on match, refuses on mismatch) — with the real attestation fn restored, provingSkipAttestationis the live bypass, not the test stub.GOWORK=off go build ./... && go vet ./... && go test -race ./...all green; edited files gofmt-clean.Follow-up (web4)
The standalone
cmd/updaterlives in web4, not this module. A--skip-attestationflag / env should be threaded there to surfaceConfig.SkipAttestation, mirroring the existing--state-pathflag. Nocmd/exists in this repo, so nothing to thread here.